Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sqlsmith, deterministic-test): deterministic fuzz stability #7967

Merged
merged 25 commits into from
Feb 24, 2023

Conversation

kwannoel
Copy link
Contributor

@kwannoel kwannoel commented Feb 16, 2023

I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.

What's changed and what's your intention?

#7978

  • Adds 32 different sets of ddl + queries. This is run by deterministic test.
  • Daily cron will still run the usual seeded deterministic test.
  • PR and main workflow will run with the queries in freeze.zip in deterministic test environment.
  • Adds generate + run_pre_generated commands to sqlsmith.

Checklist

  • I have written necessary rustdoc comments
  • I have added necessary unit tests and integration tests
  • I have added fuzzing tests or opened an issue to track them. (Optional, recommended for new SQL features).
  • I have demonstrated that backward compatibility is not broken by breaking changes and created issues to track deprecated features to be removed in the future. (Please refer to the issue)
  • All checks passed in ./risedev check (or alias, ./risedev c)

Documentation

  • My PR DOES NOT contain user-facing changes.
Click here for Documentation

Types of user-facing changes

Please keep the types that apply to your changes, and remove the others.

  • Installation and deployment
  • Connector (sources & sinks)
  • SQL commands, functions, and operators
  • RisingWave cluster configuration changes
  • Other (please specify in the release note below)

Release note

@kwannoel kwannoel force-pushed the deterministic-fuzz-stability branch from 521b9af to a7fd394 Compare February 16, 2023 08:27
@kwannoel kwannoel marked this pull request as ready for review February 16, 2023 08:29
@kwannoel kwannoel force-pushed the deterministic-fuzz-stability branch from 8b44f88 to a7fd394 Compare February 16, 2023 08:30
@kwannoel kwannoel force-pushed the deterministic-fuzz-stability branch from 14c1980 to a67fb87 Compare February 16, 2023 10:51
@codecov
Copy link

codecov bot commented Feb 16, 2023

Codecov Report

Merging #7967 (646de18) into main (1e0c0d2) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #7967      +/-   ##
==========================================
- Coverage   71.63%   71.63%   -0.01%     
==========================================
  Files        1132     1132              
  Lines      182213   182213              
==========================================
- Hits       130526   130523       -3     
- Misses      51687    51690       +3     
Flag Coverage Δ
rust 71.63% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/object_store/src/object/mem.rs 86.87% <0.00%> (-0.39%) ⬇️
src/storage/src/hummock/compactor/iterator.rs 96.40% <0.00%> (-0.28%) ⬇️
src/common/src/types/ordered_float.rs 30.87% <0.00%> (-0.20%) ⬇️
src/storage/src/hummock/sstable_store.rs 64.77% <0.00%> (-0.16%) ⬇️
src/storage/src/hummock/compactor/mod.rs 80.88% <0.00%> (+0.19%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@kwannoel
Copy link
Contributor Author

Bump, can someone help to review this? Thanks!

Ok(_) => tracing::info!("successfully wrote to {}", path.display()),
}
}

/// e2e test runner for sqlsmith
pub async fn run(client: &tokio_postgres::Client, testdata: &str, count: usize) {
let mut rng = rand::rngs::SmallRng::from_entropy();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just came up with an idea: Can we make queries deterministic if we provide a fixed seed for this RNG?

The current from_entropy reads from the global RNG in the simulation test. If the execution path before this point changes (likely to happen when RW code developed), the initial state of this RNG changes as well. I guess that's why queries are not stable across PRs. 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay let's try it first before this PR, that is simple change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kwannoel
Copy link
Contributor Author

Made redundant by #8047? Let's observe deterministic-test fuzzing's stability for the next week or so...

@kwannoel
Copy link
Contributor Author

obsolete after #8068

@kwannoel kwannoel closed this Feb 21, 2023
@fuyufjh
Copy link
Member

fuyufjh commented Feb 23, 2023

Another advantage of a fixed test set is that it allows us to ignore some cases. I guess this might be very useful, because there are lots of corner cases in SQL and expressions and most of these corner cases are unlikely to happen in real-world use cases. Instead of fixing them immediately, I tend to record first and mark them as low-priority bugs.

Also, if we have the ability to ignore/disable a test case temporarily, it would be much easier to enable more features in SQLSmith because it won't be blocked by fixing these bugs. You can simply create these GitHub issues and ask the assignee to re-enable these ignored case once the bug gets fixed.

BTW, if you don't like to check in these random cases, we could open a separated GitHub repo to store them. BuildKite allows us to do it easily.

What do you think? @kwannoel @lmatz

@lmatz
Copy link
Contributor

lmatz commented Feb 23, 2023

Instead of fixing them immediately, I tend to record first and mark them as low-priority bugs.
we have the ability to ignore/disable a test case temporarily,

Both agree

what about making fuzz testing a separate pipeline, and allowing merging a PR even when it fails?
But failed PR should open/link an issue of this failed test case

@kwannoel kwannoel reopened this Feb 23, 2023
@kwannoel
Copy link
Contributor Author

kwannoel commented Feb 23, 2023

Agree to both as well.

what about making fuzz testing a separate pipeline, and allowing merging a PR even when it fails?
But failed PR should open/link an issue of this failed test case.

I think we should block PR still if fuzz testing with pre-generated queries fail. Property of pre-generated query set is that when they were generated, either:
A) Some queries are disabled because of bugs. i.e. these are commented out in the generated test set and won't be ran.
B) The rest should pass.

If any query fails then, it is failing from B). This should indicate a regression caused by the PR. So the PR should not be merged still.

@kwannoel
Copy link
Contributor Author

kwannoel commented Feb 23, 2023

PTAL, ready for review @lmatz @jon-chuang @fuyufjh @wangrunji0408.

Also, if we have the ability to ignore/disable a test case temporarily, it would be much easier to enable more features in SQLSmith because it won't be blocked by fixing these bugs.

Will re-enable inserts and try this approach in a separate PR.

}

/// e2e query generator
/// The goal is to generate NON-FAILING queries.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can support ignoring cases, this seems not necessary any more. In my mind, we can generate cases regardless of success of failure, and then mark to ignore thse unsupported ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, plan to work on this in a separate PR.

@mergify mergify bot merged commit d257b5f into main Feb 24, 2023
@mergify mergify bot deleted the deterministic-fuzz-stability branch February 24, 2023 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants